package com.gitee.shoes.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.gitee.shoes.crawler.bean.ApiTradeType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author LYH
 */
@RequiredArgsConstructor
public enum TradeType {
    // 闲置
    leave("leave");

    @EnumValue
    @Getter
    private final String text;

    public static TradeType newInstance(ApiTradeType apiTradeType) {
        if (apiTradeType == null) {
            return null;
        }
        for (TradeType value : values()) {
            if (value.name().equals(apiTradeType.name()) || value.getText().equals(apiTradeType.name())) {
                return value;
            }
        }
        return null;
    }
}
